package ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class DelOperation implements IOperation{
    @Override
    public void word(BookList bookList) {
        Book[] books = bookList.getBooks();
        System.out.println("请输入要删除的书籍名字");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getUseSize(); i++) {
            if(name.equals(bookList.getPosBook(i).getName())){
                for (int j = i; j < bookList.getUseSize() - 1; j++) {
                    books[j] = books[j+1];
                }
                books[bookList.getUseSize()-1] = null;
                bookList.setUseSize(bookList.getUseSize()-1);
                System.out.println("删除成功");
                return;
            }
        }
        System.out.println("找不到你要的书籍");

    }
}
